package com.haotunet.app.goldtreasure.utils;

public class LocationUtils {
	public static double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

	public static double[] gcj02_To_Bd09(double lat, double lon) {
		double x = lon, y = lat;
		double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
		double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
		double tempLon = z * Math.cos(theta) + 0.0065;
		double tempLat = z * Math.sin(theta) + 0.006;
		double[] gps = { tempLat, tempLon };
		return gps;
	}

	public static double[] Bd09_To_gcj02(double bd_lat, double bd_lon) {
		double gg_lat = 0;
		double gg_lon = 0;
		double x = bd_lon - 0.0065, y = bd_lat - 0.006;

		double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);

		double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);

		gg_lon = z * Math.cos(theta);

		gg_lat = z * Math.sin(theta);
		double[] gps = { gg_lat, gg_lon };
		return gps;

	}
}
